package Util;

import org.springframework.stereotype.Component;

import javax.websocket.*;
import javax.websocket.server.ServerEndpoint;

/**
 * Created by studio on 2017/3/17.
 */

@ServerEndpoint(value = "/websocket")
@Component
public class MyWebsocket {
    @OnOpen
    public void onOpen(Session session){
        System.out.println("连接成功");
    }

    @OnClose
    public void onClose(){
        System.out.println("连接关闭");
    }

    @OnMessage
    public void onMessage(String message,Session session){
        System.out.println("来自客户端的信息:" + message);
    }

    @OnError
    public void onError(Session session,Throwable error){
        System.out.println("错误:" + error.getMessage());
    }
}
